package com.shenfa.dao;

import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.shenfa.bean.xml.PointInfo;
import com.shenfa.bean.xml.UserBase;

/**
 * 客户账单处理Dao
 * @author zys (2011-10-07)
 *
 */
public class CustomerBillDao {

	@Autowired
	private SqlMapClient sqlMapClient;
	
	private UserBase ub;
	
	private Object obj;
	
	private PointInfo pi;
	/**
	 * 插入客户账单记录信息
	 * @param list
	 * @return
	 */
	public int insertCustomerBill(List<String> list,String personid) {	
		
		ub = new UserBase();
		ub.setSystem_name(list.get(0));
		ub.setData_date(list.get(1));
		ub.setAcctnbr(list.get(2));
		ub.setRectype(list.get(3));
		ub.setZip(list.get(4));
		ub.setAddrname3(list.get(5));
		ub.setAddrname1(list.get(6));
		ub.setAddrname2(list.get(7));
		ub.setName(list.get(8));
		ub.setSex(list.get(9));
		ub.setBirthday(list.get(10));
		ub.setAccnum(list.get(11));
		ub.setCusnum(list.get(12));
		ub.setStfromdate(list.get(13));
		ub.setEnddate(list.get(14));
		ub.setSpecode(list.get(15));
		ub.setPmtduemark(list.get(16));
		ub.setCashmark(list.get(17));
		ub.setIndiv1(list.get(18));
		ub.setIndiv2(list.get(19));
		ub.setIndiv3(list.get(20));
		ub.setIndiv4(list.get(21));
		ub.setIndiv5(list.get(22));
		ub.setIndiv6(list.get(23));
		ub.setIndiv7(list.get(24));
		ub.setIndiv8(list.get(25));
		ub.setActinfo(list.get(26));
		ub.setDm1(list.get(27));
		ub.setDm2(list.get(28));
		ub.setDm3(list.get(29));
		ub.setDm4(list.get(30));
		ub.setBrandmsg1(list.get(31));
		ub.setBrandmsg2(list.get(32));
		ub.setBrandmsg3(list.get(33));
		ub.setBrandmsg4(list.get(34));
		ub.setBrandmsg5(list.get(35));
		ub.setBrandmsg6(list.get(36));
		ub.setBrandmsg7(list.get(37));
		ub.setConvexchmark(list.get(38));
		ub.setVipmsg1(list.get(39));
		ub.setVipmsg2(list.get(40));
		ub.setVipmsg3(list.get(41));
		ub.setVipmsg4(list.get(42));
		ub.setReprintflag(list.get(43));
		ub.setEmailflag(list.get(44));
		ub.setPaperflag(list.get(45));
		ub.setEmailaddr(list.get(46));
		ub.setCusttype(list.get(47));
		ub.setMobilenbr(list.get(48));
		ub.setAinbr(list.get(49));
		ub.setMobdate(list.get(50));
		ub.setFiller(list.get(51));
		ub.setFlag1(list.get(52));
		ub.setFlag2(list.get(53));
		ub.setPersonid(personid);
	
		try {
			obj = sqlMapClient.insert("customerbill_manager.cusbill", ub);

		} catch (SQLException e) {
			e.printStackTrace();
			return -1;
		}
		return 0;
	}
	
	/**
	 * 插入客户账单人民币汇总信息
	 * @param list
	 * @return
	 */
	public int insertRMBBill(List<String> list) {
		ub.setSystem_name(list.get(0));
		ub.setData_date(list.get(1));
		ub.setAcctnbr(list.get(2));
		ub.setRectype(list.get(3));
		ub.setStmtdate(list.get(4));
		ub.setPmtdate(list.get(5));
		ub.setTotbagbal(list.get(6));
		ub.setPlantotpmt(list.get(7));
		ub.setTotnomalamt(list.get(8));
		ub.setTotadjamt(list.get(9));
		ub.setIntdueamt(list.get(10));
		ub.setCurrbal(list.get(11));
		ub.setTotdueamt(list.get(12));
		ub.setPmtprint(list.get(13));
		ub.setCrlim(list.get(14));
		ub.setCashcrlim(list.get(15));
		ub.setAchrtnbr(list.get(16));
		ub.setAchdbnbr(list.get(17));
		ub.setProjachnpmt(list.get(18));
		ub.setPmtachflag(list.get(19));
		ub.setAchflag(list.get(20));
		ub.setPmtflag(list.get(21));
		ub.setFiller(list.get(22));
		ub.setFlag1(list.get(23));
		ub.setFlag2(list.get(24));
		try {
			obj = sqlMapClient.insert("customerbill_manager.cusRMBbill", ub);
		} catch (SQLException e) {
			e.printStackTrace();
			return -1;
		}	
		return 0;
	}
	
	/**
	 * 插入客户账单人民币明细信息
	 * @param list
	 * @return
	 */
	public int insertRMBDetailBill(List<String> list) {
		
		ub.setSystem_name(list.get(0));
		ub.setData_date(list.get(1));
		ub.setAcctnbr(list.get(2));
		ub.setRectype(list.get(3));
		ub.setRecseq(list.get(4));
		ub.setEffdate(list.get(5));
		ub.setPostdate(list.get(6));
		ub.setCardnbrlast4(list.get(7));
		ub.setDesc(list.get(8));
		ub.setTxnamt(list.get(9));
		ub.setPurchasecity(list.get(10));
		ub.setFiller(list.get(11));
		ub.setFlag1(list.get(12));
		ub.setFlag2(list.get(13));
		ub.setSrctxnamt(list.get(14));
		ub.setSrctxncurr(list.get(15));
		ub.setStmtdate(list.get(16));
		try {
			obj = sqlMapClient.insert("customerbill_manager.cusRMBDetail", ub);
		} catch (SQLException e) {
			e.printStackTrace();
			return -1;
		}	
		return 0;
	}
	
	/**
	 * 插入客户账单美元汇总信息
	 * @param list
	 * @return
	 */
	public int insertDollarBill(List<String> list) {
		
		ub.setSystem_name(list.get(0));
		ub.setData_date(list.get(1));
		ub.setAcctnbr(list.get(2));
		ub.setRectype(list.get(3));
		ub.setStmtdate(list.get(4));
		ub.setPmtdate(list.get(5));
		ub.setTotbagbal(list.get(6));
		ub.setPlantotpmt(list.get(7));
		ub.setTotnomalamt(list.get(8));
		ub.setTotadjamt(list.get(9));
		ub.setIntdueamt(list.get(10));
		ub.setCurrbal(list.get(11));
		ub.setTotdueamt(list.get(12));
		ub.setPmtprint(list.get(13));
		ub.setCrlim(list.get(14));
		ub.setCashcrlim(list.get(15));
		ub.setAchrtnbr(list.get(16));
		ub.setAchdbnbr(list.get(17));
		ub.setProjachnpmt(list.get(18));
		ub.setPmtachflag(list.get(19));
		ub.setPmtflag(list.get(20));
		ub.setFiller(list.get(21));
		ub.setFlag1(list.get(22));
		ub.setFlag2(list.get(23));
		try {
			obj = sqlMapClient.insert("customerbill_manager.cusDollarbill", ub);
			
		} catch (SQLException e) {
			e.printStackTrace();
			return -1;
		}	
		return 0;
	}
	
	/**
	 * 插入客户账单美元明细信息
	 * @param list
	 * @return
	 */
	public int insertDollarDetailBill(List<String> list) {
		
		ub.setSystem_name(list.get(0));
		ub.setData_date(list.get(1));
		ub.setAcctnbr(list.get(2));
		ub.setRectype(list.get(3));
		ub.setRecseq(list.get(4));
		ub.setEffdate(list.get(5));
		ub.setPostdate(list.get(6));
		ub.setCardnbrlast4(list.get(7));
		ub.setDesc(list.get(8));
		ub.setTxnamt(list.get(9));
		ub.setSrctxnamt(list.get(10));
		ub.setSrctxncurr(list.get(11));
		ub.setSrcpurcity(list.get(12));
		ub.setFiller(list.get(13));
		ub.setFlag1(list.get(14));
		ub.setFlag2(list.get(15));
		try {
			obj = sqlMapClient.insert("customerbill_manager.cusDollarDetail", ub);
			
		} catch (SQLException e) {
			e.printStackTrace();
			return -1;
		}	
		return 0;
	}
	
	/**
	 * 插入客户账单购汇信息
	 * @param list
	 * @return
	 */
	public int insertPurchase(List<String> list) {	
		
		ub.setSystem_name(list.get(0));
		ub.setData_date(list.get(1));
		ub.setAcctnbr(list.get(2));
		ub.setRectype(list.get(3));
		ub.setExchusdamt(list.get(4));
		ub.setSellrate(list.get(5));
		ub.setExchrmbamt(list.get(6));
		ub.setAchrtnbr(list.get(7));
		ub.setAchdbnbr(list.get(8));
		ub.setFiller(list.get(9));
		ub.setFlag1(list.get(10));
		try {
			obj = sqlMapClient.insert("customerbill_manager.cusPurchase", ub);
			
		} catch (SQLException e) {
			e.printStackTrace();
			return -1;
		}	
		return 0;
	}
	
	/**
	 * 插入客户账单借记卡人民币交易
	 * @param list
	 * @return
	 */
	public int insertCardRMB(List<String> list) {
		
		ub.setSystem_name(list.get(0));
		ub.setData_date(list.get(1));
		ub.setAcctnbr(list.get(2));
		ub.setRectype(list.get(3));
		ub.setCusnum(list.get(4));
		ub.setEffdate(list.get(5));
		ub.setDesc(list.get(6));
		ub.setPurchasecity(list.get(7));
		ub.setCurrcode(list.get(8));
		ub.setTxnamt((list.get(9)));
		ub.setCardnbrlast4(list.get(10));
		ub.setFiller(list.get(11));	
		try {
			obj = sqlMapClient.insert("customerbill_manager.cusCardRMB", ub);
		
		} catch (SQLException e) {
			e.printStackTrace();
			return -1;
		}	
		return 0;
	}
	
	/**
	 * 插入客户账单借记卡美元明细
	 * @param list
	 * @return
	 */
	public int insertCardDollar(List<String> list) {
		
		ub.setSystem_name(list.get(0));
		ub.setData_date(list.get(1));
		ub.setAcctnbr(list.get(2));
		ub.setRectype(list.get(3));
		ub.setCusnum(list.get(4));
		ub.setEffdate(list.get(5));
		ub.setDesc(list.get(6));
		ub.setPurchasecity(list.get(7));
		ub.setCurrcode(list.get(8));
		ub.setTxnamt((list.get(9)));
		ub.setCardnbrlast4(list.get(10));
		ub.setFiller(list.get(11));
		try {
			obj = sqlMapClient.insert("customerbill_manager.cusCardDollar", ub);
		
		} catch (SQLException e) {
			e.printStackTrace();
			return -1;
		}	
		return 0;
	}
	
	/**
	 * 更新特殊账单个性化信息
	 * @param list
	 */
	public int updGXH(String inSR) {
		
		ub.setAcctnbr(inSR.substring(0, 16));
		ub.setIndiv1(inSR.substring(16, 17));
		ub.setIndiv2(inSR.substring(17, 18));
		ub.setIndiv3(inSR.substring(18, 19));
		ub.setIndiv4(inSR.substring(19, 20));
		ub.setIndiv5(inSR.substring(20, 21));
		ub.setIndiv6(inSR.substring(21, 22));
		ub.setIndiv7(inSR.substring(22, 23));
		ub.setIndiv8(inSR.substring(23, 24));
		ub.setDm1(inSR.substring(24, 25));
		ub.setDm2(inSR.substring(25, 26));
		ub.setDm3(inSR.substring(26, 27));
		ub.setDm4(inSR.substring(27, 28));
		try {
			obj = sqlMapClient.update("customerbill_manager.upd_gxh", ub);
			
		} catch (SQLException e) {
			e.printStackTrace();
			return -1;
		}
		return 0;
	}
	
	/**
	 * 插入客户账单万里通积分信息
	 * @param list
	 * @return
	 */
	public int insertWLT(String[] list) {
	
		pi.setEcifno(list[0]);
		pi.setEndpoint(list[1]);
		pi.setNewpoint(list[2]);
		pi.setUsedpoint(list[3]);
		pi.setAdjustpoint(list[4]);
		pi.setInvailpoint(list[5]);
		pi.setValidpointB(list[6]);
		pi.setBilldate(list[7]);
		try {
			obj = sqlMapClient.insert("customerbill_manager.insertWLT", pi);
		} catch (SQLException e) {
			e.printStackTrace();
			return -1;
		}
		return 0;
	}
	
	/**
	 * 插入客户账单携程积分信息
	 * @param list
	 * @return
	 */
	public int insertXC(String[] list) {
		pi = new PointInfo();
		pi.setPointtype(list[0]);
		pi.setCardportid(list[1]);
		pi.setBusinessid(list[2]);
		pi.setAblepoint(list[3]);
		pi.setLastbalpoint(list[4]);
		pi.setAddpoint(list[5]);
		pi.setExpoint(list[6]);
		pi.setAdpoints(list[7]);
		pi.setEndpoints(list[8]);
		pi.setEcifno(list[9]);
		pi.setStartdate(list[10]);
		pi.setEnddate(list[11]);
		pi.setWholeconsume(list[12]);
		pi.setInconsume(list[13]);
		pi.setOutconsume(list[14]);
		pi.setWholemoney(list[15]);
		pi.setInmoney(list[16]);
		pi.setOutmoney(list[17]);
		pi.setUsedmoney(list[18]);
		pi.setLavemoney(list[19]);
		pi.setValiddate(list[20]);
		pi.setLaddermoney(list[21]);
		pi.setLadderscale(list[22]);
//		pi.setBilldate(list.get(23));
		pi.setCardlast4(list[23]);
//		pi.setPointcardtype(list.get(25));
		try {
			obj = sqlMapClient.insert("customerbill_manager.insertXC", pi);
		} catch (SQLException e) {
			e.printStackTrace();
			return -1;
		}
		return 0;
	}
	
	/**
	 * 更新普通账单个性化信息
	 * @param list
	 */
	public int updGxh(String inSR) {
		
		ub.setAcctnbr(inSR.substring(0, 16));
		ub.setIndiv1(inSR.substring(16, 17));
		ub.setIndiv2(inSR.substring(17, 18));
		ub.setIndiv3(inSR.substring(18, 19));
		ub.setIndiv4(inSR.substring(19, 20));
		ub.setIndiv5(inSR.substring(20, 21));
		ub.setIndiv6(inSR.substring(21, 22));
		ub.setIndiv7(inSR.substring(22, 23));
		ub.setIndiv8(inSR.substring(23, 24));
		ub.setDm1(inSR.substring(24, 25));
		ub.setDm2(inSR.substring(25, 26));
		ub.setDm3(inSR.substring(26, 27));
		ub.setDm4(inSR.substring(27, 28));
		try {
			obj = sqlMapClient.update("customerbill_manager.upd_Gxh", ub);
			
		} catch (SQLException e) {
			e.printStackTrace();
			return -1;
		}
		return 0;
	}
	
	
}
